/**
 * @copyright SilverBiology, LLC
 * @author SilverBiology, LLC
 * @website http://www.silverbiology.com
*/

Ext.ns("BioBlitz");

BioBlitz.SettingPanel = function(config){
	
	var fusion_id ;		

	Ext.apply(this, config, { 
			scroll: 'vertical'
		, cls: 'frm'
		,	id:'settingpanel'
		,	defaults: {
			}
		,	draggable : false
		,	items: [{
					xtype: 'fieldset'					
				, cls: 'frm'
				,	title: 'General Settings'
//                    instructions: 'Please enter the information above.',
				,	defaults: {
							required: true
						,	labelAlign: 'left'
						,	draggable : false
					}
				,	items: [{
							xtype: 'textfield'
						,	name: 'fusionID'
						,	fieldLabel: 'Local ID'
						,	id: 'fusionID'
						,	floatable: true
						,	labelHeight: '100'
					}, {
							xtype: 'textfield'
						,	name: 'masterID'
						,	label: 'Master ID'
						,	id: 'masterID'
						,	disabled: false
					}, {
							xtype: 'textfield'
						,	name: 'name'
						,	label: 'Collector Name'
						,	id: 'collectorname'
						,	disabled: false
					}]
			}]
			,	dockedItems: [{
						xtype: 'toolbar'
					,	dock: 'top'
					,	title: "Settings"
					,	items: [{
							xtype: 'spacer'
						}, {
								text: 'Save'
//							,	ui: 'action'
							,	scope:this
							,	handler: function() {
									fusion_id = this.getValues().fusionID
									localStorage.setItem("fusionid", this.getValues().fusionID);
									localStorage.setItem("masterid", this.getValues().masterID);
									localStorage.setItem("name", this.getValues().name);
									alert("Settings Saved");
									//this.reset();
								}
					 }]
				}]
			,	listeners: {
					activate: this.loadData
				}
	});

	BioBlitz.SettingPanel .superclass.constructor.call(this,config);
	
}

Ext.extend(BioBlitz.SettingPanel , Ext.form.FormPanel, {
		loadData: function(){
			var user = Ext.ModelMgr.create({
					fusionID: localStorage.getItem("fusionid")
				,	masterID: localStorage.getItem("masterid")
				,	name: localStorage.getItem("name")
			}, 'Setting');

			this.load(user);
		}
});	